<?php
namespace app\home\model;
use think\Model;
use think\Db;
class Article extends Model
{
	//查找栏目分类
    function kind_data($kid){
      if($kid == '') return false;
      $kind = Db::name('article_kind')->where('kind_id='.$kid)->find();

      if($kind == '') return false;
      $level = $kind['level'];
      if($level == 1){
        $top_kind = $kind;
        $two_kind_list = Db::name('article_kind')->where('is_hide=0 and parent_id='.$top_kind['kind_id'])->order('sort_order')->select();
        $two_kind = Db::name('article_kind')->where('is_hide=0 and parent_id='.$top_kind['kind_id'])->order('sort_order')->find();
      }elseif($level == 2){
        $two_kind = $kind;
        $top_kind = Db::name('article_kind')->where('is_hide=0 and kind_id='.$two_kind['parent_id'])->find();
        $three_kind_list = Db::name('article_kind')->where('is_hide=0 and parent_id='.$two_kind['kind_id'])->order('sort_order')->select();
        $three_kind = Db::name('article_kind')->where('is_hide=0 and parent_id='.$two_kind['kind_id'])->order('sort_order')->find();
        $two_kind_list = Db::name('article_kind')->where('is_hide=0 and parent_id='.$top_kind['kind_id'])->order('sort_order')->select();
      }elseif($level == 3){
        $three_kind = $kind;
        $two_kind = Db::name('article_kind')->where('is_hide=0 and kind_id='.$three_kind['parent_id'])->find();
        $top_kind = Db::name('article_kind')->where('kind_id='.$two_kind['parent_id'])->find();
        $three_kind_list = Db::name('article_kind')->where('is_hide=0 and parent_id='.$two_kind['kind_id'])->order('sort_order')->select();
        $four_kind_list = Db::name('article_kind')->where('is_hide=0 and parent_id='.$three_kind['kind_id'])->order('sort_order')->select();
        $two_kind_list = Db::name('article_kind')->where('is_hide=0 and parent_id='.$top_kind['kind_id'])->order('sort_order')->select();
      }
      // elseif($level == 4){
      //   $four_kind = $kind;
      //   $three_kind = Db::name('article_kind')->where('is_hide=0 and kind_id='.$four_kind['parent_id'])->find();
      //   $two_kind = Db::name('article_kind')->where('is_hide=0 and kind_id='.$three_kind['parent_id'])->find();
      //   $top_kind = Db::name('article_kind')->where('is_hide=0 and kind_id='.$two_kind['parent_id'])->find();
      //   $five_kind_list = Db::name('article_kind')->where('is_hide=0 and parent_id='.$four_kind['kind_id'])->order('sort_order')->select();
      //   $five_kind = Db::name('article_kind')->where('is_hide=0 and parent_id='.$four_kind['kind_id'])->order('sort_order')->find();
      //   $four_kind_list = Db::name('article_kind')->where('is_hide=0 and parent_id='.$three_kind['kind_id'])->order('sort_order')->select();
      //   $three_kind_list = Db::name('article_kind')->where('is_hide=0 and parent_id='.$two_kind['kind_id'])->order('sort_order')->select();
      //   $two_kind_list = Db::name('article_kind')->where('is_hide=0 and parent_id='.$top_kind['kind_id'])->order('sort_order')->select();
      // }
      $data['top_kind'] = $top_kind;
      $data['two_kind'] = $two_kind;
      $data['two_kind_list'] = $two_kind_list;
      $data['three_kind'] = $three_kind;
      $data['three_kind_list'] = $three_kind_list;
      // $data['four_kind'] = $four_kind;
      // $data['four_kind_list'] = $four_kind_list;
      return $data;
    }















}